import React from "react";
import {renderToString} from "react-dom/server";
import express from "express";
import APP from "@/App.jsx";

const app = express();

app.use(express.static('public'))

app.get("/",(req,res)=>{
const html=renderToString(APP);
res.send(`
<!DOCTYPE html>
<html lang="en">
<head> 
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="root">${html}</div>
    <script src="/bundle.js"></script>
</body>
</html>
`);
})

app.listen(5210,()=>{
    console.log(`react-ssr server start`)
})